var base_src='http://114.215.93.162/res-web/';
var params_src=base_src+'toUploadView?type=2';
var superViewModal=function(params){
	var views='<div id="super_modal" class="modal fade" tabindex="-1" data="'+(params.data==null?'':params.data)+'">';
	views+='<div class="modal-dialog" style="width: '+params.width+'px;">';
	views+='<div class="modal-content no-padding">';
	views+='<div class="modal-header no-padding">';
	views+='<div class="table-header">';
	views+='<button type="button" class="close" data-dismiss="modal" aria-hidden="true">';
	views+='<span class="white">&times;</span>';
	views+='</button>';
	views+='<span class="fa-search-plus-winners"><i class="menu-icon fa '+params.faClass+' bigger-130""></i>&nbsp;&nbsp;'+params.title+'</span>';
	views+='</div>';
	views+='</div>';
	views+='<div class="modal-body no-padding"  style="max-height: '+params.height+'px;">';
	views+=params.content;
	views+='<div class="hr hr-dotted"></div>';
	views+='<div class="wizard-actions" style="padding: 10px 20px;">';
	views+='<button class="btn btn-sm btn-success btn-baocun" type="button">';
	views+='<i class="ace-icon fa fa-check bigger-110"></i>';
	views+='<span class="bigger-110 no-text-shadow">确定</span>';
	views+='</button>';
	views+='<button class="btn btn-sm btn-warning btn-quxiao"  type="button">';
	views+='<i class="ace-icon fa fa-fire bigger-110"></i>';
	views+='<span class="bigger-110 no-text-shadow">取消</span>';
	views+='</button>';									
	views+='</div>';
	views+='</div>';
	views+='</div><!-- /.modal-content -->';
	views+='</div><!-- /.modal-dialog -->';
	$(document.body).append(views);
	var _modal = $('#super_modal').modal({backdrop: 'static', keyboard: false});
	$('.btn-quxiao').click(function(){
		_modal.modal('hide');

	});
	$('.btn-baocun').click(function(){
		params.callback();
	});
	_modal.on('hidden.bs.modal', function () {
		$('#super_modal').remove();
	})
	return _modal;

}
var superViewModal1=function(params){
	var views='<div id="super_modal" class="modal fade" tabindex="-1" data="'+(params.data==null?'':params.data)+'">';
	views+='<div class="modal-dialog" style="width: '+params.width+'px;">';
	views+='<div class="modal-content no-padding">';
	views+='<div class="modal-header no-padding">';
	views+='<div class="table-header">';
	views+='<button type="button" class="close" data-dismiss="modal" aria-hidden="true">';
	views+='<span class="white">&times;</span>';
	views+='</button>';
	views+='<span class="fa-search-plus-winners"><i class="menu-icon fa '+params.faClass+' bigger-130""></i>&nbsp;&nbsp;'+params.title+'</span>';
	views+='</div>';
	views+='</div>';
	views+='<div class="modal-body no-padding"  style="max-height: '+params.height+'px;">';
	views+=params.content;
	views+='<div class="hr hr-dotted"></div>';
	views+='</div>';
	views+='</div><!-- /.modal-content -->';
	views+='</div><!-- /.modal-dialog -->';
	$(document.body).append(views);
	var _modal = $('#super_modal').modal({backdrop: 'static', keyboard: false});
	_modal.on('hidden.bs.modal', function () {
		$('#super_modal').remove();
	})
	return _modal;
	
}

var superFrameModal=function(params){	
	var views='<div id="superFrameModal" class="modal fade" tabindex="-1" data="'+(params.data==null?'':params.data)+'">';
		views+='<div class="modal-dialog" style="width: '+params.width+'px;">';
		views+='<div class="modal-content no-padding">';
		views+='<div class="modal-header no-padding">';
		views+='<div class="table-header">';
		views+='<button type="button" class="close" data-dismiss="modal" aria-hidden="true">';
		views+='<span class="white">&times;</span>';
		views+='</button>';
		views+='<span class="fa-search-plus-winners"><i class="menu-icon fa '+(typeof(params.faClass) == "undefined"||params.faClass==null?'fa-picture-o':params.faClass)+' bigger-130""></i>&nbsp;&nbsp;'+params.title+'</span>';
		views+='</div>';
		views+='</div>';
		views+='<div class="modal-body no-padding"  style="max-height: '+params.height+'px;">';
		views+='<iframe runat="server" width="'+(params.width-2)+'" height="'+params.height+'" src="'+params.src+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>';
		views+='</div>';
		views+='</div><!-- /.modal-content -->';
		views+='</div><!-- /.modal-dialog -->';
	$(document.body).append(views);
	var _modal = $('#superFrameModal').modal({backdrop: 'static', keyboard: false});
	_modal.on('hidden.bs.modal', function () {
		  $('#superFrameModal').remove();
	})
	
	return _modal;
}
var ResFrameModal=function(params){	
	var views='<div id="ResFrameModal" class="modal fade" tabindex="-1" data="'+(typeof(params.data) == "undefined"||params.data==null?'':params.data)+'">';
		views+='<div class="modal-dialog" style="width: '+900+'px;">';
		views+='<div class="modal-content no-padding">';
		views+='<div class="modal-header no-padding">';
		views+='<div class="table-header">';
		views+='<button type="button" class="close" data-dismiss="modal" aria-hidden="true">';
		views+='<span class="white">&times;</span>';
		views+='</button>';
		views+='<span class="fa-search-plus-winners"><i class="menu-icon fa '+(typeof(params.faClass) == "undefined"||params.faClass==null?'fa-picture-o':params.faClass)+' bigger-130""></i>&nbsp;&nbsp;'+(typeof(reValue) == "undefined"||params.title==null?'资源管理器':params.title)+'</span>';
		views+='</div>';
		views+='</div>';
		views+='<div class="modal-body no-padding"  style="max-height: '+550+'px;">';
		views+='<iframe runat="server" width="'+(900-2)+'" height="'+550+'" src="'+params_src+'&t='+new Date().getTime()+'" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>';
		views+='</div>';
		views+='</div><!-- /.modal-content -->';
		views+='</div><!-- /.modal-dialog -->';
	$(document.body).append(views);
	var _modal = $('#ResFrameModal').modal({backdrop: 'static', keyboard: false});
	_modal.on('hidden.bs.modal', function () {
		  $('#ResFrameModal').remove();
	})
	return _modal;
}

window.addEventListener('message', function(e){
	var file=eval("("+e.data.file+")");
	callback(file)	
	try{
		$('#ResFrameModal').remove();
	}catch(e){}
	$('#superFrameModal').remove();
}, false);

function gritterAlert(params){
	params=params==null?{}:params;
	$.gritter.add({
		time : typeof(params.time)!= 'undefined'? params.time:2000,  
	    speed: typeof(params.speed)!= 'undefined'? params.speed:500,  
	    position: typeof(params.position)!= 'undefined'? params.position:'bottom-right',  
		title: typeof(params.title)!= 'undefined'? params.title:'提示',
		sticky: false,  
		text: params.text || typeof(params.text)!= 'undefined'? params.text:'说点什么？？',
		class_name: typeof(params.class_name)!= 'undefined'? params.class_name:'gritter-success'
	});
}
Date.prototype.format = function(format)
{
 var o = {
 "M+" : this.getMonth()+1, //month
 "d+" : this.getDate(),    //day
 "h+" : this.getHours(),   //hour
 "m+" : this.getMinutes(), //minute
 "s+" : this.getSeconds(), //second
 "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
 "S" : this.getMilliseconds() //millisecond
 }
 if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
 (this.getFullYear()+"").substr(4 - RegExp.$1.length));
 for(var k in o)if(new RegExp("("+ k +")").test(format))
 format = format.replace(RegExp.$1,
 RegExp.$1.length==1 ? o[k] :
 ("00"+ o[k]).substr((""+ o[k]).length));
 return format;
}